Skip to content

Fix/deprecations memory leak entitlements - #2147

Merged
FastestMolasses merged 5 commits into
CodeEditApp:mainfrom
vksvicky:fix/deprecations-memory-leak-entitlements
Dec 12, 2025
Merged

Fix/deprecations memory leak entitlements#2147
FastestMolasses merged 5 commits into
CodeEditApp:mainfrom
vksvicky:fix/deprecations-memory-leak-entitlements

Conversation

@vksvicky

@vksvicky vksvicky commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

This PR fixes multiple issues related to macOS 14 compatibility, compiler warnings, and a memory leak.

Description

  • ✅ Updated macOS deployment target from 13.0 to 14.0
  • ✅ Fixed 80+ SwiftUI onChange(of:perform:) deprecation warnings
  • ✅ Fixed unreachable code warning in LSPService.swift
  • ✅ Added required app entitlements for file access (fixes crash on file dialogs)
  • ✅ Fixed memory leak in CurrentUser.getCurrentUser()

Related Issues

#2133

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • [] My changes are all related to the related issue above
  • [] I documented my code

Screenshots

Resolves build errors with test frameworks (XCTest, Testing) that
require macOS 14.0+. This fixes the following linker warnings:
- Building for macOS-13.0 but linking with XCTest built for 14.0
- Building for macOS-13.0 but linking with libXCTestSwiftSupport built for 14.0
- Building for macOS-13.0 but linking with Testing framework built for 14.0
- Updated 80+ instances of onChange(of:perform:) to use the new
  macOS 14.0+ syntax with two-parameter closures (_, newValue in)
- Commented out unreachable code in LSPService.swift after early return
- Updated Xcode project settings to version 16.1 (LastUpgradeCheck: 2610)
- Enabled app sandbox and JIT runtime exceptions for proper execution
- Added string catalog symbol generation

This resolves all deprecation warnings when targeting macOS 14.0+.

Files affected: 39 files
Changes: 95 insertions(+), 76 deletions(-)
- Fixed remaining onChange(of:perform:) calls that used explicit 'perform:' label
- Updated onChange calls with capture lists to use new two-parameter syntax
- Simplified capture list patterns as new onChange provides both old and new values

Files fixed:
- WorkspacePanelTabBar.swift
- EditorTabButtonStyle.swift
- EditorTabs.swift (2 instances)
- ExtensionsListView.swift

All onChange deprecation warnings now resolved.
The app was crashing with REPORT_APP_ENTITLEMENTS_INSUFFICIENT when
trying to open file/folder dialogs from the Welcome screen.

Added necessary entitlements:
- com.apple.security.app-sandbox: Enable App Sandbox
- com.apple.security.files.user-selected.read-write: Allow user-selected file access
- com.apple.security.files.bookmarks.app-scope: Allow bookmark persistence
- com.apple.security.network.client: Enable network access for extensions/LSP

This resolves the crash when clicking "Open File or Folder" button.
Fixed memory leak where an UnsafeMutablePointer<passwd> was allocated
but never deallocated.

Issue Analysis:
- Line 43 was allocating heap memory for `result` pointer
- getpwuid_r() immediately overwrites `result` to point to `pwd` (stack)
- The allocated heap memory was leaked on every call
- Attempting to deallocate crashed because `result` pointed to stack memory

Root Cause:
The allocation was unnecessary. getpwuid_r() expects `result` as an
output parameter - it sets the pointer itself, no pre-allocation needed.

Solution:
Removed the unnecessary .allocate(capacity: 1) call. Now `result` is
initialized as nil and getpwuid_r() sets it to point to `pwd` on success.

This function is called every time a terminal is opened, so the leak
would accumulate with each terminal session.
@FastestMolasses
FastestMolasses merged commit 78c3be9 into CodeEditApp:main Dec 12, 2025
1 of 2 checks passed
matthijseikelenboom added a commit to matthijseikelenboom/CodeEdit that referenced this pull request Aug 22, 2026
Five build configs carry ENABLE_APP_SANDBOX = NO and the entitlements
file has no app-sandbox key, with nothing in the repo saying why. A
reviewer had no way to tell a deliberate decision from a leftover.

The sandbox blocks Process from spawning subprocesses, which is what
ShellClient, CETerminal, and every git path depend on, so this is the
project's long-standing configuration rather than a workaround. PR CodeEditApp#2147
enabled it by accident in December as part of an unrelated fix and broke
git, LSP, the terminal, and package installs; commit a2fff0c reverted
that. Recording the history so the next person does not repeat it.

Also notes the two consequences: App Store distribution is out of scope,
and the security-scoped bookmark handling is a deliberate no-op kept for
the case where this is revisited.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants